Skip to content

fix: preserve wrapped function metadata in register() decorator#3

Open
neox-d wants to merge 1 commit into
frappe:mainfrom
neox-d:fix/preserve-wrapper-module
Open

fix: preserve wrapped function metadata in register() decorator#3
neox-d wants to merge 1 commit into
frappe:mainfrom
neox-d:fix/preserve-wrapper-module

Conversation

@neox-d
Copy link
Copy Markdown

@neox-d neox-d commented Apr 16, 2026

The mcp.register() decorator replaces the user's endpoint function with an inner
wrapper, but doesn't copy over module, name, etc.

On Frappe v17, frappe.whitelist() unconditionally wraps every function with validate_argument_types, which resolves the app name at decoration time via func.module.split(".")[0]. Without @functools.wraps, this resolves to
"frappe_mcp" instead of the user's app, causing Frappe to load frappe_mcp.hooks - which doesn't exist since frappe_mcp is a pip package, not a Frappe app.

The register() decorator replaces the user's endpoint function with an inner
  wrapper, but doesn't copy over __module__, __name__, etc.

  On Frappe v17, frappe.whitelist() unconditionally wraps every function with validate_argument_types, which resolves the app name at decoration time via func.__module__.split(".")[0]. Without @functools.wraps, this resolves to
  "frappe_mcp" instead of the user's app, causing Frappe to load frappe_mcp.hooks — which doesn't exist since frappe_mcp is a pip package, not a Frappe app.
@neox-d
Copy link
Copy Markdown
Author

neox-d commented Apr 16, 2026

Hey @18alantom, raised this PR to fix a crash on Frappe v17. Can you look into it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant